package com.exer1.servlet;

import com.exer1.pojo.Dormitory;
import com.exer1.service.DormitoryService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @ClassName SelectDormitoryServlet
 * @Description 查询全部宿舍信息
 * @Author Kx
 * @Date 2025/4/24 0:20
 * @Version 1.0
 */
@WebServlet("/SelectDormitoryServlet")
public class SelectDormitoryServlet extends HttpServlet {

    // 实例化业务层对象
    private final DormitoryService dormitoryService = new DormitoryService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 调用方法
        List<Dormitory> allDormitory = dormitoryService.findALLDormitory();

        // 遍历输出
        for (Dormitory dormitory : allDormitory) {
            System.out.println(dormitory);
        }
    }
}
